/*
  In App.xaml:
  <Application.Resources>
      <vm:ViewModelLocator xmlns:vm="clr-namespace:Project1"
                           x:Key="Locator" />
  </Application.Resources>
  
  In the View:
  DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}"

  You can also use Blend to do all this with the tool's support.
  See http://www.galasoft.ch/mvvm
*/

using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Ioc;
using CommonServiceLocator;
using GalaSoft.MvvmLight.Views;
using CommonLib;
using System;

namespace Project1.ViewModel
{
    /// <summary>
    /// This class contains static references to all the view models in the
    /// application and provides an entry point for the bindings.
    /// </summary>
    public class ViewModelLocator
    {
        /// <summary>
        /// Initializes a new instance of the ViewModelLocator class.
        /// </summary>
        public ViewModelLocator()
        {

            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
            SimpleIoc.Default.Register<CoreViewModel>();
            SimpleIoc.Default.Register<RegistViewModel>();
            SimpleIoc.Default.Register<ModelMeasureFactoryVM>();
            SimpleIoc.Default.Register<ModelRegisterFactoryVM>();
        }

        //private INavigationService CreateNavigationService()
        //{
        //    var nav = new NavigationService();

        //    var navigationService = new NavigationService();
        //    navigationService.Configure("UCC", new Uri("/Project1;component/Pages/UserControlCircle.xaml", UriKind.Relative));
        //    navigationService.Configure("UCCL", new Uri("/Project1;component/Pages/UserControlLLine.xaml", UriKind.Relative));
        //    navigationService.Configure("UCCP", new Uri("/Project1;component/Pages/UserControlPoint.xaml", UriKind.Relative));
        //    //navigationService.Configure("PageTwo4", new Uri("/Project1;component/Views/PageFour.xaml", UriKind.Relative));
        //    return navigationService;
        //}
        public CoreViewModel Core
        {
            get
            {
                return ServiceLocator.Current.GetInstance<CoreViewModel>();
            }
        }

        public RegistViewModel Regist
        {
            get
            {
                return ServiceLocator.Current.GetInstance<RegistViewModel>();
            }
        }
        public ModelMeasureFactoryVM  Measure 
        {
            get
            {
                return ServiceLocator.Current.GetInstance<ModelMeasureFactoryVM>();
            }
        }

        public ModelRegisterFactoryVM Register
        {
            get { return ServiceLocator.Current.GetInstance<ModelRegisterFactoryVM>(); }
        }
        public static void Cleanup()
        {
            // TODO Clear the ViewModels
        }
    }
}